package com.zhiyou100.ajax;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @packageName: ${NAME}
 * @className: ${PACKAGE_NAME}
 * @Description: TODO ajax t2 测试 post 方法
 * @author: yang
 * @date: 7/24/20
 */
@WebServlet(name = "t2", urlPatterns = "/ajax/t2")
public class t2 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("post  方法被请求了！！1");
        request.setCharacterEncoding("UTF-8");
        // 设定编码集
        response.setContentType("text/html;charset=UTF-8");
        // 设定类型

        String name = request.getParameter("name");
        response.getWriter().write("请求方式：get?name=" + name + ",time:" + (System.currentTimeMillis()));

    }


}
